<template>
  <div class="post-container">
    <h1 class="article-title">{{ article.title }}</h1>
    <div class="info-block">
      <a href="" class="avatar-link"
        ><Avatar v-if="article.avatar" :url="article.avatar" :size="40"
      /></a>
      <div class="author-info-box">
        <div class="author-name">
          <a href="" class="username"><span>{{article.username}}</span></a>
        </div>
        <div class="meta-box">
          <div class="time">{{formatDate(article.createDate)}}</div>
          <span class="views-count">·&nbsp;&nbsp;阅读 {{article.scanNumber}}</span>
        </div>
      </div>
      <div class="follow-button">+关注</div>
    </div>
    <div v-html="article.htmlContent" class="markdown-body"></div>
  </div>
</template>

<script>
import Avatar from "@/components/Avatar";
import getArticle from "@/api/getArticle";
import formatDate from '@/utils/formatDate'
export default {
  data() {
    return {
      article: {},
    };
  },
  components: {
    Avatar,
  },
  async created() {
    const resp = await getArticle();
    this.article = resp;
  },
  methods:{
    formatDate,
  }
};
</script>

<style scoped lang="less">
@import "~@/styles/var.less";
@import "~@/styles/common.less";
@import '~@/styles/markdown.css';
@import "highlight.js/styles/github.css";
.post-container {
  padding: 30px;
  .article-title {
    margin: 0 0 1.667rem;
    font-size: 2.667rem;
    font-weight: 600;
    line-height: 1.31;
    color: #252933;
  }
  .info-block {
    display: flex;
    align-items: center;
    margin-bottom: 1.667rem;
    .avatar-link {
      text-decoration: none;
      cursor: pointer;
      color: #909090;
      margin-right: 12px;
    }
    .author-info-box {
      min-width: 0;
      flex-grow: 1;
      flex: 1;
      min-height: 43px;
      .author-name {
        height: 1.5rem;
        .username {
          display: flex;
          align-items: center;
        }
      }
      .meta-box {
        font-size: 1.167rem;
        color: #8a919f;
        margin-top: 2px;
        line-height: 22px;
        .time {
          letter-spacing: 1px;
          display: inline-block;
          margin-right: 5px;
        }
      }
    }
    .follow-button {
      color: #515767;
      background: rgba(81, 87, 103, 0.05);
      border-color: rgba(81, 87, 103, 0.3);
      margin: 0 0 0 auto;
      padding: 0 1rem;
      height: 34px;
      font-size: 14px;
      color: @active;
      background: rgba(30, 128, 255, 0.05);
      border: 1px solid rgba(30, 128, 255, 0.3);
      border-radius: 4px;
      display: flex;
      align-items: center;
      cursor: pointer;
    }
  }
}
</style>